const Koa = require('koa');
const app = new Koa()
const router = require('koa-route');

const logger = (ctx, next) => {
  console.log(`${ctx.url}--${ctx.method}--${new Date()}`);
  next()
}

const home = (ctx) => {
  ctx.body = '<h2>首页</h2>'
}
const about = (ctx) => {
  ctx.body = '<a href="/home"> 去首页 </a>'
}


app.use(logger)  // 中间件
app.use(router.get('/home', home))
app.use(router.get('/about', about))



app.listen(3000, () => {
  console.log('listening on 3000');
})